/*
 * @Description:
 * @Author: cgt
 * @Date: 2021-12-23 14:05:56
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 18:28:19
 */
import ITool from '../ITool';

/**
 * 搜索工具箱
 * @implements {ITool}
 */
class SearchTool extends ITool {
  constructor(_top, _impl) {
    super(_top, _impl);
    this.name = 'SearchTool';
    this.desc = '搜索工具箱';
  }

  onAdd() {
    super.onAdd();
  }

  onRemove() {
    super.onRemove();
  }

  /**
   * 地理位置查询
   * @param {Object} params 参数
   */
  searchByMap(params) {
    // 默认关掉结果坐标加密
    params.isEncode = params.isEncode || false;
    console.log(params);
    let placeSearchTask = new SGMap.PlaceSearchTask();
    return placeSearchTask.searchPlace(params);
  }

  /**
   * 电网设备查询
   * @param {Object} params 参数
   */
  searchByServer(params) {
    // 默认传输schema为fzgh
    if (!params.schema) {
      params.schema = 'fzgh';
    }
    return this.getApi().PwghGhsjTxfw.pattern.post_pattern_searchEquipList({
      params: params
    });
  }
}

export default SearchTool;